package com.hctg.forced2sleep.service;

import android.os.Build;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.actor.myandroidframework.utils.MMKVUtils;

/**
 * description: 屏蔽通知消息
 * company    :
 * @author    : ldf
 * date       : 2024/10/5 on 13:49
 */
public class NotifyService extends NotificationListenerService {

//    public static NotifyService f3331c;
//    public int f3332b = 0;

    @Override // android.app.Service
    public void onCreate() {
        super.onCreate();
//        f3331c = this;
    }

    @Override // android.service.notification.NotificationListenerService
    public void onListenerConnected() {
        super.onListenerConnected();
    }

    @Override // android.service.notification.NotificationListenerService
    public void onNotificationPosted(StatusBarNotification statusBarNotification, RankingMap rankingMap) {
        super.onNotificationPosted(statusBarNotification, rankingMap);
        String packageName = statusBarNotification.getPackageName();
//        DingConfigUtil.getInstance().getClass();
        //                                                  todo:
        if (MMKVUtils.getBoolean("receiverMessage", true) /*&& DingFloat.i()*/) {
            try {
                // TODO: 2024/10/5
//                if (WhiteEventEngine.getInstance().i(packageName)) {
//                    return;
//                }
                if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) {
                    cancelNotification(statusBarNotification.getKey());
                } else {
                    cancelNotification(statusBarNotification.getPackageName(), statusBarNotification.getTag(), statusBarNotification.getId());
                }
//                this.f3332b++;
//                DingConfigUtil.getInstance().getClass();
                MMKVUtils.putInt("notify_count", MMKVUtils.getInt("notify_count", 0) + 1);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}
